package com.example.myapplication.base.activity

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity

abstract class BaseActivity : AppCompatActivity() {


    private var _savedInstanceState: Bundle? = null

    private var isLazedView = false

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        _savedInstanceState = savedInstanceState
        isLazedView = false
        bindContent()
    }

    open fun bindContent() {
        val contentView = onBindContent()
        if (contentView != null) {
            setContentView(contentView)
        }
    }

    abstract fun onBindContent(): View?


    override fun onResume() {
        super.onResume()
        if (!isLazedView) {
            onLazyView(_savedInstanceState)
            _savedInstanceState = null
        }
    }

    protected abstract fun onLazyView(savedInstanceState: Bundle?)


}